<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function CreateCat(name) {
        this.name = name;
      }
      /*
       *new 做了哪些操作
       *1.创建一个空对象
       *2.将构造函数的prototype属性赋值给新对象的__proto__属性
       *3.将构造函数的this指向新对象
       *4.执行构造函数的代码
       *5.将新对象返回
       */
      var catB = (function () {
        var obj = {};
        obj.__proto__ = CreateCat.prototype;
        CreateCat.call(obj, "A");
        return obj;
      })();
      console.log(catB);
    </script>
  </body>
</html>
